<script setup></script>

<template>
  <div>
    <router-view></router-view>
  </div>
</template>

<script setup>
import { onMounted } from "vue";
import { useUserStore } from "@/store";

const userStore = useUserStore();

onMounted(() => {
  initializeUser();
});

function initializeUser() {
  const savedUserInfo = sessionStorage.getItem("userInfo");
  console.log("savedUserInfo", savedUserInfo);
  if (savedUserInfo) {
    try {
      const parsedUserInfo = JSON.parse(savedUserInfo);
      userStore.setUser(parsedUserInfo);
    } catch (error) {
      console.error("Failed to parse userinfo from sessionStorage", error);
    }
  }
}
</script>
<style scoped></style>
